<template>
    <div id="fixed-assets" class="w-h-100 pos-r flex-1 apply-container page-public-s" style="box-sizing: border-box;overflow:hidden;">
        <div class="w-h-100 ver-flex pos-a" style="box-sizing: border-box; padding: 6px;">
            <div v-if="$hasPer('DrillPlan:add') || $hasPer('DrillPlan:excel')" style="box-sizing: border-box;">
                <el-card shadow="never" :body-style="{ paddingBottom: '0' }">
                    <el-form class="box-f" ref="queryForm" :inline="true">
                        <el-form-item >
                            <el-button @click="nodeClick('','add')" icon="ele-Plus" type="primary"> 新增 </el-button>
                            <el-button @click="batchUpload(0)" icon="ele-Upload"> 批量上传 </el-button>
                            <el-button @click="batchUpload(1)" icon="ele-Download"> 模板下载 </el-button>
                            <el-button @click="handleExport" icon="ele-Download"> 导出数据 </el-button>
                        </el-form-item>
                    </el-form>
                </el-card>
            </div>

            <div style="box-sizing: border-box;" class="flex-1 pos-r">
                <div class="pos-a w-h-100" style="box-sizing: border-box;">
                    <el-card class="box-card w-h-100" shadow="never" style="margin-top: 16px;">
                        <div style="" class="w-h-100 ver-flex">
                            <div class="flex-1 pos-r">
                                <div class="pos-a w-h-100">
                                    <el-table ref="excelRef" :data="list" class="w-h-100" style="width: 100%" border v-loading="loading" element-loading-background="rgba(0, 0, 0, 0.5)">
                                        <!-- <el-table-column type="index" label="序号" width="55" :show-overflow-tooltip="true" align="center" :index="indexMethod" /> -->
                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="资产编码"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_AssetNo" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_AssetNo">{{ scope.row.v_AssetNo }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="资产名称"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Name" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Name">{{ scope.row.v_Name }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="资产分类名称"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Mode" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Name">{{ scope.row.v_Name }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="规格"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Specification" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Specification">{{ scope.row.v_Specification }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" prop="" label="型号"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Model" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Model">{{ scope.row.v_Model }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="原值"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_OriginalValue" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_OriginalValue">{{ scope.row.v_OriginalValue }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="管理部门"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_ManageOrgId" typeVal="cascader" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_ManageOrgName">{{ scope.row.v_ManageOrgName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="使用部门"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_UseOrgId" typeVal="cascader" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_UseOrgName">{{ scope.row.v_UseOrgName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="管理人"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_ManagerId" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_ManagerName">{{ scope.row.v_ManagerName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="使用人"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_UserId" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_UserName">{{ scope.row.v_UserName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="位置"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Place" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Place">{{ scope.row.v_Place }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="资产状态"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_State" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.n_State === 0" style="color: #67C23A;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 1" style="color: #E6A23C;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 2" style="color: #409EFF;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 3" style="color: #F56C6C;">{{ scope.row.v_StateName }}</span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="180" :show-overflow-tooltip="true" prop="createdTime" label="创建时间"  align="center" sortable>
                                            <template #default="scope">
                                                <span v-if="scope.row.createdTime">{{ scope.row.createdTime }}</span>
                                                <span v-else>-</span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="180" :show-overflow-tooltip="true" prop="updatedTime" label="更新时间"  align="center" sortable>
                                            <template #default="scope">
                                                <span v-if="scope.row.updatedTime">{{ scope.row.updatedTime }}</span>
                                                <span v-else>-</span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column width="260" label="操作" align="center" fixed="right">
                                            <el-table-column :show-overflow-tooltip="true" min-width="260" align="center">
                                                <template #header>
                                                    <el-button class="icon-e" @click='searchClick' icon="ele-Search" size="small" type="primary" text> 查询 </el-button>
                                                    <el-button class="icon-e clear-bg" style="background-color: transparent !important;" size="small" @click="resetClick" icon="ele-Refresh" text> 重置 </el-button>
                                                </template>
                                                <template #default="scope">
                                                    <div class="operate-s">
                                                        <el-button @click="detailHandle(scope.row.id)" class="icon-e" icon="ele-View" size="small" text type="success">详情</el-button>
                                                        <el-button v-if="$hasPer('DrillPlan:edit')" @click="nodeClick(scope.row,'edit')" class="icon-e" icon="ele-Edit" size="small" text type="warning">编辑</el-button>
                                                        <el-button v-if="$hasPer('DrillPlan:del')" @click="deleteHandle(scope.row.id, getData)" class="icon-e" icon="ele-Delete" size="small" text type="danger">删除</el-button>
                                                    </div>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>
                                    </el-table>
                                </div>
                            </div>
                            <div style="height: 30px;margin-top: 20px;" class="hr-flex-start">
								<el-pagination
									v-model:currentPage="pageNo"
									v-model:page-size="pageSize"
									:total="totalRows"
									:page-sizes="[10, 20, 50, 100]"
									small
									background
									@size-change="handleSizeChange"
									@current-change="handleCurrentChange"
									layout="total, sizes, prev, pager, next, jumper"
									class="w-h-100"
								/>
							</div>
                        </div>
                    </el-card>
                </div>
            </div>
        </div>
        <!-- 新增/编辑 -->
        <AddEditFixedAssets
            :repairInfo="repairInfo"
            :isUseDialog="isUseDialog"
            @updateData="getData"
            @cancelUseClick="cancelUseClick"
            @controlUseClick="controlUseClick"
        />
        <!-- 批量上传 -->
        <MassUpload
            :isBase="false"
            :neddUrl="needUrl"
            :isUseDialog="massDialog"
            @updateData="getData"
            @cancelMassClick="cancelMassClick"
            @controlMassClick="controlMassClick"
        />
        <!-- 详情 -->
        <DetailModel
            :detailInfo="detailInfo"
            :MdetailDialog="MdetailDialog"
            labelWidth="120px"
            @cancelDetailClick="cancelDetailClick"
        />
    </div>
</template>
<script lang="ts">
import { defineComponent, ref, Ref, onMounted , reactive , toRaw } from 'vue';
import getTableData from '/@/utils/getTableData';
import { 
    SMSAssFixedAssetLedgerPage , 
    SMSAssFixedAssetLedgerDelete , 
    sysDictDataList , 
    SMSAssFixedAssetLedgerDetail ,
    SMSAssFixedAssetLedgerBathAddByExcel,
} from '/@/api/centerControl/sms';
import AddEditFixedAssets from '../component/sms/add-edit-FixedAssets.vue';
import MassUpload from '../component/sms/mass-upload.vue';
import { ElMessageBox , ElMessage } from 'element-plus';
import { sysOrgTree , sysEmpSelector } from '/@/api/centerControl/pubilc';
import SearchModel from '../component/search-model.vue';
import DetailModel from '../component/detail-model.vue';
import { exportToExcel } from '/@/utils/exportToExcel';

export default defineComponent( {
    name: 'fixed-assets',
    components: {
        AddEditFixedAssets,
        SearchModel,
        DetailModel,
        MassUpload,
    },
    setup(props){
        const isUseDialog = ref() // 新增/编辑弹出框隐藏/显示
        const repairInfo = ref() // 传递子组件数据

        /*** 新增/编辑点击事件 */
        const nodeClick = (val:string | object , am:string) => {
            val !== '' ? repairInfo.value = JSON.stringify(toRaw(val)) : repairInfo.value = ''
            isUseDialog.value = true
        };

        /*** 删除数据事件 */
        const deleteHandle = async (val: String | Number, updateFun: Function) => {
            ElMessageBox.confirm('请确定删除此条数据？','提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }
            )
            .then(async() => {
                let param = {id : val}
                try {
                    let res:any = await SMSAssFixedAssetLedgerDelete(param);
                    if(res.success){
                        updateFun()
                    }
                } catch (err) { return }
            })
            .catch(() => {
                ElMessage({
                    type: 'info',
                    message: '已取消',
                })
            })
        };

        /*** 取消事件 */
        const cancelUseClick = () => {
            isUseDialog.value = false
        };

        /*** 提交事件 */
        const controlUseClick = () => {
            isUseDialog.value = false
        };

        /*** ================================= 批量上传 =================================  */
        const massDialog = ref(false);
        const baseUrl = import.meta.env.VITE_API_URL;
        /*** 上传/下载点击事件 */
        const batchUpload = (num: number) => {
            if(num === 0) { massDialog.value = true; }
            if(num === 1){
                // window.open(baseUrl + 'api/Upload/sms/ExcelTempFiles/固定资产台账导入模板.xlsx' , '_blank') // 打开新页面
                window.location.href = baseUrl + '/Upload/SMS/ExcelTempFiles/固定资产台账导入模板.xlsx'; // 当前页面中打开
            }
        }

        /*** 批量上传取消事件 */
        const cancelMassClick = () => {
            massDialog.value = false;
        }

        /*** 批量上传提交事件 */
        const controlMassClick = () => {
            massDialog.value = false;
        }
        /*** ================================= 批量上传 =================================  */

        /*** ================================= 详情类数据操作 =================================  */
        const MdetailDialog = ref(false);
        const detailInfo = ref();

        /*** 获取详情接口数据 */
        const getDetailFun = async (id: number) => {
            let res: any = await SMSAssFixedAssetLedgerDetail({id: id}); // 详情
            if(res.success){
                let setArr: any = [];
                let detailObj: any = {};
                detailObj['资产编码'] = res.data.v_AssetNo ? res.data.v_AssetNo : '-';
                detailObj['资产名称'] = res.data.v_Name ? res.data.v_Name : '-';
                detailObj['资产分类名称'] = res.data.v_AssetType ? res.data.v_AssetType : '-';
                detailObj['规格'] = res.data.v_Specification ? res.data.v_Specification : '-';
                detailObj['型号'] = res.data.v_Model ? res.data.v_Model : '-';
                detailObj['原值'] = res.data.v_OriginalValue ? res.data.v_OriginalValue : '-';
                detailObj['管理部门'] = res.data.v_ManageOrgName ? res.data.v_ManageOrgName : '-';
                detailObj['使用部门'] = res.data.v_UseOrgName ? res.data.v_UseOrgName : '-';
                detailObj['管理人'] = res.data.v_ManagerName ? res.data.v_ManagerName : '-';
                detailObj['使用人'] = res.data.v_UserName ? res.data.v_UserName : '-';
                detailObj['位置'] = res.data.v_Place ? res.data.v_Place : '-';
                detailObj['资产状态'] = res.data.v_StateName ? res.data.v_StateName : '-';
                if(res.data.equipmentInfo){
                    let detailObjTwo: any = {};
                    let item = res.data.equipmentInfo;
                    let v_RunningStatusName = '';
                    let v_MaintainStatusName = '';
                    let v_AssetStatusName = '';
                    let v_isSpecial = '';

                    if(item.n_RunningStatus === 1) v_RunningStatusName = '运行';
                    if(item.n_RunningStatus === 2) v_RunningStatusName = '待机';
                    if(item.n_RunningStatus === 3) v_RunningStatusName = '停机';

                    if(item.n_MaintainStatus = 1) v_MaintainStatusName = '正常';
                    if(item.n_MaintainStatus = 2) v_MaintainStatusName = '维修';
                    if(item.n_MaintainStatus = 3) v_MaintainStatusName = '保养';

                    if(item.n_AssetStatus = 1) v_AssetStatusName = '在用';
                    if(item.n_AssetStatus = 2) v_AssetStatusName = '报废';

                    // if(item.isSpecial === 0) v_isSpecial = '否';
                    // if(item.isSpecial === 1) v_isSpecial = '是';

                    detailObjTwo['设备编码'] = item.v_Code ? item.v_Code : '-';
                    detailObjTwo['设备名称'] = item.v_Name ? item.v_Name : '-';
                    detailObjTwo['所属系统'] = item.v_System ? item.v_System : '-';
                    detailObjTwo['设备类型'] = item.v_Type ? item.v_Type : '-';
                    detailObjTwo['规格型号'] = item.v_SpeciModel ? item.v_SpeciModel : '-';
                    detailObjTwo['运行时间(小时)'] = item.n_RunTime ? item.n_RunTime : '-';
                    detailObjTwo['服务区域'] = item.v_ServiceArea ? item.v_ServiceArea : '-';
                    detailObjTwo['安装位置'] = item.v_Location ? item.v_Location : '-';
                    detailObjTwo['运行状态'] = v_RunningStatusName;
                    detailObjTwo['维护状态'] = v_MaintainStatusName;
                    detailObjTwo['资产状态'] = v_AssetStatusName;
                    detailObjTwo['运行状态采集点'] = item.v_RunningStatus ? item.v_RunningStatus : '-';
                    // detailObjTwp['是否是特种设备'] = v_isSpecial;
                    setArr.push({
                        formTitle: '设备信息',
                        type: 'form',
                        info: detailObjTwo,
                    });
                }
                setArr.push({
                    formTitle: '资产台账基础信息',
                    type: 'form',
                    info: detailObj,
                });
                detailInfo.value = setArr;
                MdetailDialog.value = true;
            }
        }
        /*** 详情 */
        const detailHandle = (id: number) => {
            getDetailFun(id);
        }
        /*** 详情关闭事件 */
        const cancelDetailClick = () => {
            MdetailDialog.value = false;
        }
        /*** ================================= 详情类数据操作 =================================  */
        
        /*** ================================= 查询类数据操作 =================================  */
        let searchObj:any = reactive({});
        const basicsInfo: any = ref([]);
        const searInfo: any = ref();

        /*** 获取需要查询的数据 */
        const searchHandel = (val: any) => {
            searInfo.value = val;
        }

        /*** 查询按钮 */
        const searchClick = () => {
            let newObj = Object.keys(searInfo.value);
            if(newObj.length !== 0){
                newObj.map((i:any) => {
                    searchObj[i] = searInfo.value[i];
                });
            }
        };

        /*** 重置按钮 */
        const resetClick = () => {
            searInfo.value = {};
            let newObj = Object.keys(searchObj);
            if(newObj.length !== 0){
                newObj.map((i:any) => {
                    searchObj[i] = ''
                });
            }
            initInfoFun();
        };

        let orgArr: any = [];
        let modeArr: any = [];
        let useArr: any = [];
        // 获取数据
        const getFun = async () => {
            let ras: any = await sysOrgTree({}); // 获取组织架构树
            let rbs: any = await sysDictDataList({TypeCode: 'AssetType'}); // 资产分类
            let rcs: any = await sysEmpSelector({}); // 员工数据
            if(ras.success && ras.data.length !== 0){
                orgArr = ras.data;
            }
            if(rbs.success && rbs.data.length !== 0) {
                rbs.data.map((item: any) => {
                    item.label = item.value;
                    item.value = item.value;
                });
                modeArr = rbs.data;
            }
            if(rcs.success && rcs.data.length !== 0) {
                rcs.data.map((item: any) => {
                    item.label = item.name;
                    item.value = item.id;
                });
                useArr = rcs.data;
            }
        }
        
        /*** 初始化数据 */
        const initInfoFun = () => {
            basicsInfo.value = [{
                    typeId: 'i_AssetNo', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_AssetNo', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '资产编码', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_Name', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_Name', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '资产名称', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_ManageOrgId', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_ManageOrgId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '管理部门', // placeholder数据
                    defaultProp: orgArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                    propsVal: { checkStrictly: true , label: 'title', value: 'id', children: 'children' }, // 级联选择器 --- 选填
                },{
                    typeId: 's_UseOrgId', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_UseOrgId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '使用部门', // placeholder数据
                    defaultProp: orgArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                    propsVal: { checkStrictly: true , label: 'title', value: 'id', children: 'children' }, // 级联选择器 --- 选填
                },{
                    typeId: 'i_Model', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_Model', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '型号', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_Specification', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_Specification', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '规格', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Mode', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_AssetType', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '资产分类名称', // placeholder数据
                    defaultProp: modeArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_OriginalValue', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_OriginalValue', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '原值', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_ManagerId', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_ManagerId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '管理人', // placeholder数据
                    defaultProp: useArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_UserId', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_UserId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '使用人', // placeholder数据
                    defaultProp: useArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_Place', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_Place', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '位置', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_State', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'n_State', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '资产状态', // placeholder数据
                    defaultProp: [
                        {label: '启用', value: 0},
                        {label: '停用', value: 1},
                        {label: '备用', value: 2},
                        {label: '报废', value: 3},
                    ], // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                }
            ]
        }
        
        onMounted(async () => {
            await getFun();
            initInfoFun(); 
        });
        /*** ================================= 查询类数据操作 =================================  */

        /*** ================================= 导出数据函数操作 ================================= */
        const excelRef: any = ref(null);
        const handleExport = () => {
            if(excelRef.value){
                if(excelRef.value.data.length !== 0){
                    let tableExcel: any = [];
                    let tableArr = excelRef.value.data;
                    tableArr.map((item: any) => {
                        let tableObj: any = {};
                        tableObj['资产编码'] = item.v_AssetNo ? item.v_AssetNo : '-';
                        tableObj['资产名称'] = item.v_Name ? item.v_Name : '-';
                        tableObj['资产分类名称'] = item.v_AssetType ? item.v_AssetType : '-';
                        tableObj['规格'] = item.v_Specification ? item.v_Specification : '-';
                        tableObj['型号'] = item.v_Model ? item.v_Model : '-';
                        tableObj['原值'] = item.v_OriginalValue ? item.v_OriginalValue : '-';
                        tableObj['管理部门'] = item.v_ManageOrgName ? item.v_ManageOrgName : '-';
                        tableObj['使用部门'] = item.v_UseOrgName ? item.v_UseOrgName : '-';
                        tableObj['管理人'] = item.v_ManagerName ? item.v_ManagerName : '-';
                        tableObj['使用人'] = item.v_UserName ? item.v_UserName : '-';
                        tableObj['位置'] = item.v_Place ? item.v_Place : '-';
                        tableObj['资产状态'] = item.v_StateName ? item.v_StateName : '-';
                        tableExcel.push(tableObj);
                    });
                    exportToExcel(tableExcel,'固定资产台账.xlsx');
                }else{
                    ElMessage({
                        type: 'error',
                        message: '暂无数据导出',
                    })
                }
            }
        }
        /*** ================================= 导出数据函数操作 ================================= */

        return {
            ...getTableData(SMSAssFixedAssetLedgerPage,{},searchObj),
            isUseDialog,
            cancelUseClick,
            controlUseClick,
            nodeClick,
            repairInfo,
            deleteHandle,

            // 批量上传
            batchUpload,
            needUrl: SMSAssFixedAssetLedgerBathAddByExcel,
            massDialog,
            cancelMassClick,
            controlMassClick,

            // 导出Excel
            excelRef,
            handleExport,
            
            // 详情
            MdetailDialog,
            detailHandle,
            detailInfo,
            cancelDetailClick,

            // 查询事件
            basicsInfo,
            searchHandel,
            searchClick,
            resetClick,
        }
    },
} )
</script>
<style lang="scss"> @import '../style/public.scss'; </style>
<style scoped lang="scss">
#fixed-assets {
    .box-f{
        :deep(.el-form-item__label){
            padding: 0;
        }
    }
    :deep(.el-card__body) {
        height: 100%;
    }
    :deep(.el-card){
        border: none !important;
    }
    .upload-demo{
        margin-left: 12px;
        margin-top: 2px;
    }
    ul {

        list-style: none;

        li {
            cursor: pointer;

            &:hover {
                color: red;
            }
        }
    }
    .icon-e{
        :deep(.el-icon){
            margin-right: 0px!important;
        }
    }
}
.clear-bg{
    background-color: transparent !important;
}
</style>